﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AiXiu.BLL;
using AiXiu.Model;
using AiXiu.Common;

namespace AiXiu.WebSite
{
    public partial class Phone : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        /// <summary>
        /// 登陆按钮的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //从前台获取用户输入的手机号和密码
            string phone = txtUserPhone.Text;
            string pwd = txtPassword.Text;

            //调用BLL层中的登录方法
            LoginBLL loginBLL = new LoginBLL();
            OperResult<TBUsers> result = loginBLL.LoginByPhone(phone, pwd);
            //如果返回的状态码不是成功，进行页面弹窗提示错误消息
            if (result.StatusCode != StatusCode.Succeed)
            {
                this.Alert("loginErro", result.Message);
            }
            //登录成功,缓存用户资料
            else
            {
                TBUsers users = result.Result;
                IdentityManager.SaveUser(users);
                this.AlertAndRedirect("logSuccess","登录成功！","Voide.aspx");               
            }
        }
    }
}